ToolResult

@Serializable
data class ToolResult(val toolCallId: String, val toolName: String, val outputJson: JsonElement, val output: ToolResultOutput = toolResultOutputFromJson(outputJson), val modelOutput: ToolResultOutput = output, val isError: Boolean = modelOutput is ToolResultOutput.Error || modelOutput is ToolResultOutput.ErrorJson || modelOutput is ToolResultOutput.ExecutionDenied, val preliminary: Boolean = false, val providerMetadata: Map<String, JsonElement>? = null) : StreamEvent

Tool execution emitted a result. By default this is the final result — appended to the model's message log + dispatched to UI converters.

Tools whose executor is a kotlinx.coroutines.flow.Flow (built via streamingTool { ... }) can emit intermediate progress snapshots before the final value; those land as ToolResult(preliminary = true). Preliminary results show in the UI (state stays OutputAvailable, preliminary flag set) but do NOT go to the model — the model only sees the final value once the Flow completes.

Constructors

Link copied to clipboard
constructor(toolCallId: String, toolName: String, outputJson: JsonElement, output: ToolResultOutput = toolResultOutputFromJson(outputJson), modelOutput: ToolResultOutput = output, isError: Boolean = modelOutput is ToolResultOutput.Error || modelOutput is ToolResultOutput.ErrorJson || modelOutput is ToolResultOutput.ExecutionDenied, preliminary: Boolean = false, providerMetadata: Map<String, JsonElement>? = null)

Properties

Link copied to clipboard
Link copied to clipboard
val StreamEvent.metadata: Map<String, JsonElement>?
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val outputJson: JsonElement
Link copied to clipboard
Link copied to clipboard
val providerMetadata: Map<String, JsonElement>?
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
inline fun <T> StreamEvent.providerMetadataAs(provider: String): T?
fun <T> StreamEvent.providerMetadataAs(provider: String, serializer: KSerializer<T>): T?